/*     */ package com.controller.back;
/*     */ 
/*     */ import base.dao.BaseExample;
/*     */ import base.dao.BaseExample.Criteria;
/*     */ import base.utils.ResultUtil;
/*     */ import com.model.Admin;
/*     */ import com.service.AdminService;
/*     */ import com.service.MenuService;
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpSession;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ import org.springframework.web.servlet.ModelAndView;
/*     */ import org.springframework.web.servlet.view.json.MappingJacksonJsonView;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"manage"})
/*     */ public class ManageController
/*     */ {
/*     */   @Autowired
/*     */   private AdminService adminService;
/*     */   @Autowired
/*     */   private MenuService menuService;
/*     */   
/*     */   @RequestMapping({"managelogin"})
/*     */   public ModelAndView managelogin(HttpServletRequest request)
/*     */   {
/*  41 */     ModelAndView mv = new ModelAndView();
/*  42 */     Admin admin = (Admin)request.getAttribute("admin_user");
/*  43 */     if (admin != null) {
/*  44 */       mv.setViewName("redirect:/manage/tomain.do");
/*  45 */       return mv;
/*     */     }
/*  47 */     mv.setViewName("/login.jsp");
/*  48 */     return mv;
/*     */   }
/*     */   
/*     */ 
/*     */   @RequestMapping({"tomain"})
/*     */   public ModelAndView tomain(HttpServletRequest request)
/*     */   {
/*  55 */     ModelAndView mv = new ModelAndView();
/*  56 */     HttpSession session = request.getSession();
/*  57 */     Admin t = (Admin)session.getAttribute("admin_user");
/*  58 */     if (t == null) {
/*  59 */       mv.setViewName("redirect:/manage/managelogin.do");
/*  60 */       return mv;
/*     */     }
/*  62 */     mv.addObject("url", "main.jsp");
/*  63 */     mv.setViewName("/index.jsp");
/*  64 */     return mv;
/*     */   }
/*     */   
/*     */   @RequestMapping({"exc"})
/*     */   public ModelAndView exc(HttpServletRequest request) {
/*  69 */     ModelAndView mv = new ModelAndView();
/*  70 */     HttpSession session = request.getSession();
/*  71 */     Admin t = (Admin)session.getAttribute("admin_user");
/*  72 */     if (t == null) {
/*  73 */       mv.setViewName("redirect:/manage/login.do");
/*  74 */       return mv;
/*     */     }
/*  76 */     session.removeAttribute("admin_user");
/*  77 */     mv.setViewName("redirect:/manage/managelogin.do");
/*  78 */     return mv;
/*     */   }
/*     */   
/*     */   @RequestMapping({"tologin"})
/*  82 */   public ModelAndView toLogin(HttpServletRequest request) { ModelAndView mv = new ModelAndView();
/*  83 */     Map<String, Object> attributes = new HashMap();
/*  84 */     MappingJacksonJsonView view = new MappingJacksonJsonView();
/*     */     
/*  86 */     String username = request.getParameter("name");
/*  87 */     String password = request.getParameter("pass");
/*  88 */     HttpSession session = request.getSession();
/*  89 */     Admin admin = (Admin)session.getAttribute("admin_user");
/*  90 */     if (admin == null) {
/*  91 */       BaseExample be = new BaseExample();
/*  92 */       be.or().andEqualTo("deleteFlag", Integer.valueOf(0)).andEqualTo("admin", username)
/*  93 */         .andEqualTo("password", password);
/*  94 */       List<Map<?, ?>> resList = this.adminService.selectByExample(be);
/*  95 */       if ((resList.size() == 0) || (resList == null)) {
/*  96 */         Map<String, Object> map = new HashMap();
/*  97 */         return ResultUtil.returnJsonStr("1", "用户名或密码不正确", attributes, 
/*  98 */           map, view, mv);
/*     */       }
/* 100 */       Admin admin_user = (Admin)this.adminService.selectByPrimaryKey(((Map)resList.get(0))
/* 101 */         .get("id")+"");
/* 102 */       session.setAttribute("admin_user", admin_user);
/* 103 */       Map<String, Object> map = new HashMap();
/* 104 */       return ResultUtil.returnJsonStr("0", "ok", attributes, map, view, 
/* 105 */         mv);
/*     */     }
/* 107 */     Map<String, Object> map = new HashMap();
/* 108 */     return ResultUtil.returnJsonStr("0", "ok", attributes, map, view, 
/* 109 */       mv);
/*     */   }
/*     */   
/*     */ 
/*     */   @RequestMapping({"menuList"})
/*     */   public ModelAndView menuList(HttpServletRequest request)
/*     */   {
/* 116 */     ModelAndView mv = new ModelAndView();
/*     */     
/* 118 */     HttpSession session = request.getSession();
/* 119 */     Admin t = (Admin)session.getAttribute("admin_user");
/*     */     
/* 121 */     Map<String, Object> attributes = new HashMap();
/* 122 */     MappingJacksonJsonView view = new MappingJacksonJsonView();
/*     */     
/* 124 */     String sqlmenu = "";
/*     */     
/* 126 */     sqlmenu = " WHERE  Menu.rate=1 ORDER BY sort desc ";
/*     */     
/* 128 */     String[] clauseMenu = new String[0];
/* 129 */     Object[] objMenu = new Object[0];
/* 130 */     List<Map<?, ?>> list = this.menuService.selectBySql(clauseMenu, sqlmenu, 
/* 131 */       objMenu);
/* 132 */     List<Map<String, Object>> menu = new ArrayList();
/*     */     
/* 134 */     for (Map<?, ?> m : list) {
/* 135 */       int i = 0;
/* 136 */       Map<String, Object> mm = new HashMap();
/* 137 */       String sqlmenu1 = "";
/*     */       
/* 139 */       sqlmenu1 = "  where Menu.pid=?  AND Menu.rate=2  ORDER BY Menu.sort desc ";
/*     */       
/* 141 */       String[] clauseMenu1 = new String[0];
/* 142 */       Object[] objMenu1 = { m.get("id") };
/*     */       
/* 144 */       List<Map<?, ?>> list1 = this.menuService.selectBySql(clauseMenu1, 
/* 145 */         sqlmenu1, objMenu1);
/*     */       
/* 147 */       mm.put("name", m.get("name"));
/* 148 */       mm.put("url", m.get("url"));
/* 149 */       mm.put("list", list1);
/* 150 */       menu.add(i, mm);
/* 151 */       i++;
/*     */     }
/* 153 */     attributes.put("list", menu);
/* 154 */     view.setAttributesMap(attributes);
/* 155 */     mv.setView(view);
/* 156 */     return mv;
/*     */   }
/*     */ }


/* Location:              C:\Users\chengkp\Desktop\interwar\WEB-INF\classes\!\com\controller\back\ManageController.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */